Looping through NSArray while subtracting values from each object? [on hold]
Posted
by
Julian
on Stack Overflow
See other posts from Stack Overflow
or by Julian
Published on 2013-10-26T19:57:52Z
Indexed on
2013/10/27
21:54 UTC
Read the original article
Hit count: 205
I have NSNumber objects stored in an NSMutableArray. I am attempting to perform a calculation on each object in the array.
What I want to do is:
1) Take a random higher number variable and keep subtracting a smaller number variable in increments until the value of the variable is equal to the value in the array.
For example:
NSMutableArray object is equal to 2.50.
I have an outside variable of 25 that is not in the array.
I want to subtract 0.25 multiple times from the variable until I reach less than or equal to 2.50. I also need a parameter so if the number does not divide evenly and goes below the array value, it resorts to the original array value of 2.50.
Lastly, for each iteration, I want to print the values as they are counting down as a string.
I was going to provide code, but I don't want to make this more confusing than it has to be.
So my output would be:
VALUE IS: 24.75
VALUE IS: 24.50
VALUE IS: 24.25
…
VALUE IS: 2.50
END
© Stack Overflow or respective owner